<?php
class Modelvms extends ModelBase1 {
	
	protected $tablename = '';
	
	
	private $data=null;
	
	/**
	 *
	 * @var CDbConnection
	 */
	function init(){
		global $_SGLOBAL;
		$this->_uid = $_SGLOBAL['uid'];
		$this->_vin = $_SGLOBAL['vincode'];
		$this->baseurl=$_SERVER['SERVER_NAME']."?path=services&action=vms";
	}
	
	public function getVehicleInfo($vin){
		$result = requestserver($this->baseurl."&method=".__FUNCTION__,array('data'=>$vin),'get');
		return $result;
	}
	public function updateVehicle($src){
		$data = "{VehicleInfo:".$src."}";
		$result = requestserver($this->baseurl."&method=".__FUNCTION__."&".$this->_vin,array('data'=>$data),'post');
		return $result;
	}
	public function getService(){
		$result = requestserver($this->baseurl."&method=".__FUNCTION__."&".$this->_vin,array(),'get');	
		return $result;
	}
	private function splitJson($str){
		$str = substr($str , 1,strlen($str)-2);
		$strs = explode(',',$str);
		$ret = array();
		for( $i=0;$i<count($strs);$i++ ){
			$_t = explode(':',$strs[$i]);
			$ret[trim($_t[0],"'")] = trim($_t[1],"'");
		}
		return $ret;
	}
}
?>
